VERSION 5.00
Object = "{B3FB64BF-91F9-11D7-A482-0008A14158BC}#2.22#0"; "ITGControls.ocx"
Begin VB.Form frmApprovalDetails 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Sales Order Approval (Credit Limit Details)"
   ClientHeight    =   4635
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   6945
   ControlBox      =   0   'False
   BeginProperty Font 
      Name            =   "Tahoma"
      Size            =   8.25
      Charset         =   0
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   KeyPreview      =   -1  'True
   LinkTopic       =   "Form1"
   LockControls    =   -1  'True
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   4635
   ScaleWidth      =   6945
   StartUpPosition =   1  'CenterOwner
   Begin VB.Frame Frame1 
      Height          =   4095
      Left            =   60
      TabIndex        =   12
      Top             =   60
      Width           =   6795
      Begin ITGControls.ITGLabel lblHold 
         Height          =   285
         Left            =   240
         TabIndex        =   15
         Top             =   2655
         Visible         =   0   'False
         Width           =   1755
         _ExtentX        =   3096
         _ExtentY        =   503
         BackColor       =   0
         ForeColor       =   8438015
         Caption         =   "Customer on Hold"
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Alignment       =   2
      End
      Begin ITGControls.ITGTextBox txtCL 
         Height          =   285
         Left            =   3255
         TabIndex        =   6
         Top             =   1740
         Width           =   3255
         _ExtentX        =   5530
         _ExtentY        =   503
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Text            =   "0"
         DataType        =   1
         DecimalPlace    =   2
         Locked          =   -1  'True
         Label           =   "Credit Limit"
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         TextBoxWidth    =   1695
      End
      Begin ITGControls.ITGTextBox txtAR 
         Height          =   285
         Left            =   3255
         TabIndex        =   7
         Top             =   2100
         Width           =   3255
         _ExtentX        =   5530
         _ExtentY        =   503
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Text            =   "0"
         DataType        =   1
         DecimalPlace    =   2
         Locked          =   -1  'True
         Label           =   "A/R"
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         TextBoxWidth    =   1695
      End
      Begin ITGControls.ITGTextBox txtARPD 
         Height          =   285
         Left            =   3255
         TabIndex        =   8
         Top             =   2460
         Width           =   3255
         _ExtentX        =   5530
         _ExtentY        =   503
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Text            =   "0"
         DataType        =   1
         DecimalPlace    =   2
         Locked          =   -1  'True
         Label           =   "Past Due"
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         TextBoxWidth    =   1695
      End
      Begin ITGControls.ITGTextBox txtPDC 
         Height          =   285
         Left            =   3255
         TabIndex        =   9
         Top             =   2820
         Width           =   3255
         _ExtentX        =   5530
         _ExtentY        =   503
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Text            =   "0"
         DataType        =   1
         DecimalPlace    =   2
         Locked          =   -1  'True
         Label           =   "PDC"
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         TextBoxWidth    =   1695
      End
      Begin ITGControls.ITGTextBox txtCode 
         Height          =   285
         Left            =   240
         TabIndex        =   4
         Top             =   1020
         Width           =   2580
         _ExtentX        =   4339
         _ExtentY        =   503
         SendKeysTab     =   -1  'True
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         AllCaps         =   -1  'True
         Mandatory       =   -1  'True
         Locked          =   -1  'True
         Label           =   "Customer"
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         LabelWidth      =   1320
         TextBoxWidth    =   1200
      End
      Begin ITGControls.ITGTextBox txtName 
         Height          =   285
         Left            =   2880
         TabIndex        =   13
         Top             =   1020
         Width           =   3630
         _ExtentX        =   6297
         _ExtentY        =   503
         SendKeysTab     =   -1  'True
         BackColor       =   14737632
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Locked          =   -1  'True
         Label           =   "ITGtext"
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         LabelWidth      =   0
         TextBoxWidth    =   3570
      End
      Begin ITGControls.ITGTextBox txtSONo 
         Height          =   285
         Left            =   240
         TabIndex        =   0
         Top             =   300
         Width           =   2580
         _ExtentX        =   4339
         _ExtentY        =   503
         SendKeysTab     =   -1  'True
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         AllCaps         =   -1  'True
         Mandatory       =   -1  'True
         Locked          =   -1  'True
         Label           =   "Order No."
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         LabelWidth      =   1320
         TextBoxWidth    =   1200
      End
      Begin ITGControls.ITGTextBox txtMSCode 
         Height          =   285
         Left            =   240
         TabIndex        =   5
         Top             =   1380
         Width           =   2580
         _ExtentX        =   4339
         _ExtentY        =   503
         SendKeysTab     =   -1  'True
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         AllCaps         =   -1  'True
         Mandatory       =   -1  'True
         Locked          =   -1  'True
         Label           =   "Market Segment"
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         LabelWidth      =   1320
         TextBoxWidth    =   1200
      End
      Begin ITGControls.ITGTextBox txtMSDesc 
         Height          =   285
         Left            =   2880
         TabIndex        =   14
         Top             =   1380
         Width           =   3630
         _ExtentX        =   6297
         _ExtentY        =   503
         SendKeysTab     =   -1  'True
         BackColor       =   14737632
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Locked          =   -1  'True
         Label           =   "ITGtext"
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         LabelWidth      =   0
         TextBoxWidth    =   3570
      End
      Begin ITGControls.ITGLabel lblOCL 
         Height          =   285
         Left            =   240
         TabIndex        =   16
         Top             =   2940
         Visible         =   0   'False
         Width           =   1755
         _ExtentX        =   3096
         _ExtentY        =   503
         BackColor       =   0
         ForeColor       =   8438015
         Caption         =   "Over Credit Limit"
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Alignment       =   2
      End
      Begin ITGControls.ITGLabel lblPDAR 
         Height          =   285
         Left            =   240
         TabIndex        =   17
         Top             =   3225
         Visible         =   0   'False
         Width           =   1755
         _ExtentX        =   3096
         _ExtentY        =   503
         BackColor       =   0
         ForeColor       =   8438015
         Caption         =   "w/ Past Due A/R"
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Alignment       =   2
      End
      Begin ITGControls.ITGTextBox txtCLB 
         Height          =   285
         Left            =   3255
         TabIndex        =   11
         Top             =   3540
         Width           =   3255
         _ExtentX        =   5530
         _ExtentY        =   503
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Text            =   "0"
         DataType        =   1
         DecimalPlace    =   2
         Locked          =   -1  'True
         Label           =   "Credit Limit Balance"
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         TextBoxWidth    =   1695
      End
      Begin ITGControls.ITGLabel lblRTC 
         Height          =   285
         Left            =   240
         TabIndex        =   18
         Top             =   3510
         Visible         =   0   'False
         Width           =   1755
         _ExtentX        =   3096
         _ExtentY        =   503
         BackColor       =   0
         ForeColor       =   8438015
         Caption         =   "w/ Bounced Check"
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Alignment       =   2
      End
      Begin ITGControls.ITGTextBox txtGross 
         Height          =   285
         Left            =   3255
         TabIndex        =   3
         Top             =   300
         Width           =   3255
         _ExtentX        =   5530
         _ExtentY        =   503
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Text            =   "0"
         DataType        =   1
         DecimalPlace    =   2
         Locked          =   -1  'True
         Label           =   "Order Amount"
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         TextBoxWidth    =   1695
      End
      Begin ITGControls.ITGLabel lblApproved 
         Height          =   285
         Left            =   240
         TabIndex        =   20
         Top             =   3510
         Visible         =   0   'False
         Width           =   1755
         _ExtentX        =   3096
         _ExtentY        =   503
         BackColor       =   0
         ForeColor       =   8438015
         Caption         =   "Approved"
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Alignment       =   2
      End
      Begin ITGControls.ITGTextBox txtSOAmtLeft 
         Height          =   285
         Left            =   3255
         TabIndex        =   10
         Top             =   3180
         Width           =   3255
         _ExtentX        =   5530
         _ExtentY        =   503
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Text            =   "0"
         DataType        =   1
         DecimalPlace    =   2
         Locked          =   -1  'True
         Label           =   "SO Unserved Amt"
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         TextBoxWidth    =   1695
      End
      Begin ITGControls.ITGTextBox txtTerms 
         Height          =   285
         Left            =   240
         TabIndex        =   21
         Top             =   1740
         Width           =   2580
         _ExtentX        =   4339
         _ExtentY        =   503
         SendKeysTab     =   -1  'True
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         AllCaps         =   -1  'True
         Mandatory       =   -1  'True
         Locked          =   -1  'True
         Label           =   "Customer Terms"
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         LabelWidth      =   1320
         TextBoxWidth    =   1200
      End
      Begin VB.Line Line1 
         X1              =   120
         X2              =   6660
         Y1              =   780
         Y2              =   780
      End
   End
   Begin ITGControls.ITGCommandButton cmdCancel 
      Height          =   345
      Left            =   5655
      TabIndex        =   2
      Top             =   4230
      Width           =   1200
      _ExtentX        =   2117
      _ExtentY        =   609
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Caption         =   "&Cancel"
   End
   Begin ITGControls.ITGCommandButton cmdApprove 
      Height          =   345
      Left            =   4380
      TabIndex        =   1
      Top             =   4230
      Width           =   1200
      _ExtentX        =   2117
      _ExtentY        =   609
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Caption         =   "&Approve"
   End
   Begin ITGControls.ITGCommandButton cmdOverride 
      Height          =   345
      Left            =   3090
      TabIndex        =   19
      Top             =   4230
      Visible         =   0   'False
      Width           =   1200
      _ExtentX        =   2117
      _ExtentY        =   609
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Caption         =   "&Override"
   End
End
Attribute VB_Name = "frmApprovalDetails"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private mMSCode As String
Private mGross As Double

Private Sub cmdApprove_Click()
    If Not CreditOK Then Exit Sub
    mApprovalAction = A_Approve
    Unload Me
End Sub

Private Sub cmdCancel_Click()
    mApprovalAction = A_Cancel
    Unload Me
End Sub

Private Sub cmdOverride_Click()
    If lblRTC.Visible = True Then
        MsgBox "Cannot override! Customer have unreplaced bounced check!", vbCritical, "ComUnion"
        Exit Sub
    End If
    RepName = Trim(txtSONo)
    frmOverride.mOverridingType = O_SO
    frmOverride.Show vbModal
        If gAction <> G_OK Then Exit Sub
    UpdateLogFile "Credit Approval (OR)", Trim(txtSONo), "Credit Approved (OR)"
    mApprovalAction = A_Override
    Unload Me
End Sub

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = vbKeyEscape Then
        mApprovalAction = A_Cancel
        Unload Me
    End If
End Sub

Private Sub Form_Load()
    mMSCode = GetValueFrTable("cMSCode", "SO", "cSONo = '" & mSONo & "'")
    mGross = GetValueFrTable("nNet", "SO", "cSONo = '" & mSONo & "'")
    
    Set rs = New Recordset
    CreditLimitCommand rs, mCode, mMSCode
    
    txtSONo = mSONo
    txtGross = mGross
    txtCode = mCode
    txtMSCode = mMSCode
    txtTerms.Text = GetValueFrTable("cTerm", "SO", "cSONo = '" & mSONo & "'")
    
    If rs.RecordCount = 0 Then
        MsgBox "Customer have no credit limit for a particular market segment used on sales order. Cannot approve transaction.", vbCritical, "ComUnion"
        cmdApprove.Enabled = False
    Else
        txtCL = rs!nLimit
        txtAR = rs!nAR
        txtARPD = rs!nARPastDue
        txtPDC = rs!nPDC
        txtSOAmtLeft = rs!nSOAmtLeft
        txtCLB = rs!nLimitBalance
        
        If mlCApproved Then
            cmdApprove.Enabled = False
            lblApproved.Visible = True
        Else
            If rs!lHold = True Then lblHold.Visible = True
            If rs!nARPastDue > 0 Then lblPDAR.Visible = True
            If rs!nBounced > 0 Then lblRTC.Visible = True
            If rs!nLimitBalance < mGross Then lblOCL.Visible = True
        End If
    End If
    Set rs = Nothing
End Sub

Private Sub Form_Unload(Cancel As Integer)
    
    Set frmApprovalDetails = Nothing
End Sub

Private Sub txtCode_Change()
    txtName = ""
    txtName = GetValueFrTable("cName", "CLIENT_CUSTOMER", "cCode = '" & Trim(txtCode) & "'")
End Sub

Private Sub txtMSCode_Change()
    txtMSDesc = ""
    txtMSDesc = GetValueFrTable("cDescription", "CLASSIFICATION", "cClassCode = '" & Trim(txtMSCode) & "' AND cType = 'MS'")
End Sub

Private Function CreditOK() As Boolean
Dim cHold, cOCL, cPDAR, cRTC As String
    
    CreditOK = True
    If lblHold.Visible Then
        cHold = "Customer on Hold"
        CreditOK = False
    End If
    If lblOCL.Visible Then
        cOCL = "Over Credit Limit"
        CreditOK = False
    End If
    If lblPDAR.Visible Then
        cPDAR = "With Past Due A/R"
        CreditOK = False
    End If
    If lblRTC.Visible Then
        cRTC = "With Bounced Check"
        CreditOK = False
    End If

    If Not CreditOK Then
        MsgBox "Cannot approve sales order due to following reason/s:" & vbCr & _
               cHold & IIf((cOCL <> ""), " | " & cOCL, "") & _
               IIf((cPDAR <> ""), " | " & cPDAR, "") & _
               IIf((cRTC <> ""), " | " & cRTC, ""), vbCritical, Me.Caption
        cmdOverride.Visible = True
    End If
End Function
